package jpg1980.gttunes.dao.mysql;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import org.apache.log4j.Logger;

import jpg1980.gttunes.beans.Car;
import jpg1980.gttunes.beans.DriveTrain;
import jpg1980.gttunes.beans.Manufacturer;
import jpg1980.gttunes.dao.AbstractDao;
import jpg1980.gttunes.dao.DriveTrainDao;

public class DriveTrainDaoMySqlImpl extends AbstractDao implements DriveTrainDao
{
	static Logger logger = Logger.getLogger(DriveTrainDaoMySqlImpl.class);
	
	@Override
	public int create(DriveTrain driveTrain)
	{
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public void delete(int id)
	{
		// TODO Auto-generated method stub

	}

	@Override
	public DriveTrain read(int id)
	{
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public List<DriveTrain> readAll()
	{
		List<DriveTrain> driveTrainList = new ArrayList<DriveTrain>();
		
		PreparedStatement readAllStatement;
		
		try
		{
			Connection conn = getConnection();

			logger.debug("");
			readAllStatement = conn.prepareStatement("SELECT * from DRIVETRAIN GROUP BY driveTrainName");
			ResultSet rs = readAllStatement.executeQuery();
			
			while (rs.next())
			{
				DriveTrain driveTrain = new DriveTrain(rs.getString("driveTrainName"));
				
				driveTrainList.add(driveTrain);
			}
		}
		catch (SQLException e)
		{
			super.cleanUp();
		}
		finally
		{
			super.cleanUp();
		}
		
		return driveTrainList;
	}

	@Override
	public List<DriveTrain> readSelection(int[] ids)
	{
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public void update(DriveTrain driveTrain)
	{
		// TODO Auto-generated method stub

	}

}
